/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trefliq.EJB.webservice;

import java.util.List;
import javax.ejb.EJB;
import javax.jws.WebService;
import javax.ejb.Stateless;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import trefliq.EJB.entities.Cart;
import trefliq.EJB.entities.Cart.Status;
import trefliq.EJB.entities.Movie;
import trefliq.EJB.sessionbeans.CartSession;

/**
 *
 * @author Brandon
 */
//@WebService(serviceName = "CartWebService")
@Stateless()
public class CartWebService {
    @EJB
    private CartSession ejbRef;// Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Web Service Operation")

    @WebMethod(operationName = "createCart")
    public Cart createCart(@WebParam(name = "c") Cart c) {
        return ejbRef.createCart(c);
    }

    @WebMethod(operationName = "deleteCart")
    public Cart deleteCart(@WebParam(name = "c") Cart c) {
        return ejbRef.deleteCart(c);
    }

    @WebMethod(operationName = "getAllCarts")
    public List<Cart> getAllCarts() {
        return ejbRef.getAllCarts();
    }

    @WebMethod(operationName = "getCartById")
    public Cart getCartById(@WebParam(name = "cartId") Long cartId) {
        return ejbRef.getCartById(cartId);
    }

    @WebMethod(operationName = "getCartByStatus")
    public List<Cart> getCartByStatus(@WebParam(name = "status") Status status) {
        return ejbRef.getCartByStatus(status);
    }
    
    @WebMethod(operationName = "deleteCartItem")
    @Oneway
    public void deleteCartItem(@WebParam(name = "c") Cart c, @WebParam(name = "movie") Movie movie) {
        ejbRef.deleteCartItem(c, movie);
    }

    @WebMethod(operationName = "addCartItem")
    @Oneway
    public void addCartItem(@WebParam(name = "c") Cart c, @WebParam(name = "movie") Movie movie, @WebParam(name = "quantity") int quantity) {
        ejbRef.addCartItem(c, movie, quantity);
    }
    
}
